"""
文件: basic.py
功能: 演示如何使用 multiprocessing 模块创建子进程，创建两个子进程并执行任务
"""

from multiprocessing import Process
import time


def worker(name):
    print(f"sub process {name} start")
    time.sleep(2)
    print(f"sub process {name} finsh")


if __name__ == "__main__":
    p1 = Process(target=worker, args=("A",))
    p2 = Process(target=worker, args=("B",))

    p1.start()
    p2.start()

    p1.join()
    p2.join()

    print("main process finsh")
